Talk:Goto random scene/@comment-24900619-20140514144254
Thanks, Bob. I'm still a neophyte in the forums (as well as ChoiceScript itself) and couldn't find anything about it there; but I agree with your idea of just deleting the comment here after anything useful is amalgamated. I am hoping not to step on anyone's toes here, but I found this to be a useful coding tool for myself, so I thought I would pass it along just in case. I apologize in advance if the explanation gets long-winded or I over-belabor a point; it is for the sake (hopefully) of giving the issue some clarity. Like many of us, I want to experiment with both innovative coding and clever storytelling to get the most out of the functions and tools that ChoiceScript has to offer. I learned early on that for myself I prefer a more non-linear playing experience, and since then I have decided to ditch using the *scene_list command in *startup in favor of the more flexible *goto_scene's for scene progression. So that is the first point. After reading this page, I thought, "Huh. It sure would be nice to be able to put this function to use." I even have a scene written that sort of applies to the function's ethos, which I will describe here in a sort of bare-bones fashion. I grant you this is hardly the most prominent example of its usage, but please bear with me. The player find him/herself in a small, sunny field. There are woods to the north, east, and west, and some impassable brambles to the south. Thus, assuming the player wishes to proceed onward, there are ostensibly three equal and distinct choices available. So far, very simple. The code for the basic choice would read something like: *choice #Enter the woods to the east *goto_scene enter_woods_east #Enter the woods to the west *goto_scene enter_woods_west #Enter the woods to the north *goto_scene enter_woods_north Nothing new here. Now in this scene there is also a dead tree in the middle of the field (which if you were a math major and wanted to get really technical, we could imagine as being equidistant from the field's four sides) that the player is able to discern contains a hive of bees within it. Now we include a fourth option in the choices above, along the lines of #Approach the tree *goto_scene honey_tree Where there are bees, there is often honey, and this case is no exception. The player can choose to try to take some of the honey or walk away. In the case of the latter, it simply returns him/her to the original three choices...but the former choice gets a bit more interesting. After passing a few skill checks, the player can indeed successfully take some of the honey without harm. This too will return them to the original three-way option. Without bothering over the details, there are several successful outcomes...and one failed outcome. This final one is what we are interested in, and where our function will make its debut. The (original) code for the failed outcome is as follows: You stoop down in front of the hole and reach in for some of the honey. As soon as your hand touches the inside of the tree, the background drum of buzzing becomes a roar as the bees swarm around you in a tornado of fury. They clog your eyes, nose, and mouth in seconds. In a panic you leap away from the pain and madness, running at top speed until you crash headlong into the woods. After several minutes the sound of the attackers dies away, but you are left with a swollen face and limbs--and nothing to show for it. *set health -15 *set fatigue -15 *set sanity -10 *set morale -10 *set dexterity +3 *set fortitude +5 *set luck -1 *page_break *rand odds 1 3 *if odds = 1 *goto_scene enter_woods_east *elseif odds = 2 *goto_scene enter_woods_west *else *goto_scene enter_woods_north It is obvious from the poor state the character is in that they DO NOT KNOW which of the three options they actually chose, since escaping immanent pain at the time was more of a priority. Thus, we find a simple but charming use for going to a random scene. You can see how this was done by my contrivance for generating a random choice. It is admittedly a bit of a coding eyesore, albeit effective enough. Then I began to experiment with the *goto_random_scene function--APART from any reliance on *startup or *mygame, since I am operating without a *scene_list. Whatever the function's syntax was supposed to be, this is what it is now. You stoop down in front of the hole and reach in for some of the honey. As soon as your hand touches the inside of the tree, the background drum of buzzing becomes a roar as the bees swarm around you in a tornado of fury. They clog your eyes, nose, and mouth in seconds. In a panic you leap away from the pain and madness, running at top speed until you crash headlong into the woods. After several minutes the sound of the attackers dies away, but you are left with a swollen face and limbs--and nothing to show for it. *set health -15 *set fatigue -15 *set sanity -10 *set morale -10 *set dexterity +3 *set fortitude +5 *set luck -1 *page_break *goto_random_scene enter_woods_east enter_woods_west enter_woods_north Classy! And not only pleasing to a coder's eye, but exceptionally effective as well. Finding the correct syntax, I admit, was due to some lucky guesswork... but for someone who relies or a more story-by-the-edge-of-your-seat approach rather than slide-one-slide-two-slide-three, this little function stands alone and self-sufficient as a willing companion. Sadly, there is no way to call on a *goto_random counterpart for labels that I can discern. TL;DR: You can use the function like this, too: *goto_random_scene scene_choice_A scene_choice_B scene_choice_C etc.